package auth_user

import (
	"github.com/gin-gonic/gin"
	"go-papers/models"
)

func GetThirdUserId(c *gin.Context, OpenId string) int {
	if OpenId == "" {
		return 0
	}
	var th models.ThirdUser
	th.ThridOpenId = OpenId
	thInfo, _ := th.Get()
	return thInfo.ThridUserId
}

func VerifyUid(c *gin.Context, uid, tid int) (bool, string) {
	msg := ""
	if uid == 0 && tid == 0 {
		if tid == 0 {
			msg = "用户未授权/请登陆"
		} else if uid == 0 {
			msg = "用户未登陆/请登陆"
		}
		return true, msg
	}
	return false, ""
}
